﻿using BenCaoXuan.Infrastructure.Attr;
using BenCaoXuan.Infrastructure.Dto;
using BenCaoXuan.Service.Interface.admin;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BenCaoXuan.Api.Admin.Controllers.admin
{
    [ApiGroup("Admin(管理端模块)")]
    public class HomeController : BaseController
    {
        private readonly I_Home_Service _home_Service;

        public HomeController(I_Login_Service login_Service,I_Home_Service home_Service) : base(login_Service)
        {
            _home_Service = home_Service;
        }

        /// <summary>
        /// 管理端-获取今日的静态数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Today_Data() {
            var result = await _home_Service.Get_Today_Data();
            return Ok(result);
        }

        /// <summary>
        /// 管理端-获取近7日的收入趋势数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_IncomeTrend() {
            var result = await _home_Service.Get_IncomeTrend();
            return Ok(result);
        }

        /// <summary>
        /// 管理端-获取今日预约订单
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_TodayAppointment(int page=1,int limit=5) {
            var result = await _home_Service.Get_TodayAppointment(new Fenye_Dto { 
            page=page,
            limit=limit
            });
            return Ok(result);
        }

        /// <summary>
        /// 管理端-获取订单统计数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_OrderData() {
            var result = await _home_Service.Get_OrderData();
            return Ok(result);
        }

        /// <summary>
        /// 管理端-获取消费top5的客户信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_TopCustomer() {
            var result = await _home_Service.Get_TopCustomer();
            return Ok(result);
        }
    }
}
